/**
 * User: alesj
 * Date: 2004.9.7
 * Time: 12:24:22
 */

package com.alesj.newsfeed.web.form;

import java.util.Set;

import com.alesj.newsfeed.data.Contact;
import com.alesj.newsfeed.data.GroupEntry;

import com.generalynx.common.data.IEntity;
import com.generalynx.common.resources.Resources;
import com.generalynx.ecos.web.form.AbstractSingleSelectForm;

public class ContactEntrySelectForm extends AbstractSingleSelectForm {

    protected String getHeaderLabel() {
        return Resources.getString(Resources.CONTACT);
    }

    protected String getBodyLabel() {
        return Resources.getString(Resources.FILTERS);
    }

    protected Class getEntityClass() {
        return Contact.class;
    }

    protected Class getMembersClass() {
        return GroupEntry.class;
    }

    protected Set getMembers(IEntity entity) {
        return ((Contact)entity).getEntries();
    }

    protected void postAddition(IEntity entity, IEntity member, boolean exists) {
        GroupEntry ge = (GroupEntry)member;
        ge.getContacts().add(entity);
    }

    protected void postRemoval(IEntity entity, IEntity member, boolean exists) {
        GroupEntry ge = (GroupEntry)member;
        ge.getContacts().remove(entity);
    }

}
